<template>
  <view class="search-container" :style="{'background-color' : bgColor}">
   <view class="searchbox" :style="{'border-radius' : radius + 'px'}" @click="goToSearch">
     <uni-icons type="search" size="17"></uni-icons>
     <text class="text">搜索</text>
   </view>
  </view>
</template>

<script>
  export default {
    name:"Search",
    // 为了增强通用性
    props: {
      // 背景颜色
      bgColor: {
        type: String,
        default: "#C00000"
      },
      // 圆角尺寸
      radius: {
        type: Number,
        default: 15
      }
    },
    data() {
      return {
        
      };
    },
    methods: {
      // 跳转到搜索页面
      goToSearch() {
        // 调用自定义事件
        this.$emit('click')
      }
    }
  }
</script>

<style lang="scss">
  .search-container {
    height: 50px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    .searchbox {
      background-color: #FFF;
      height: 36px;
      text-align: center;
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      line-height: 36px;
      .text {
        font-size: 15px;
        margin-left: 5px;
      }
    }
  }
</style>